using System.ComponentModel.DataAnnotations;

namespace GroupSix.Application.Dtos;

/// <summary>
/// 角色创建请求DTO
/// </summary>
public class CreateRoleRequestDto
{
    [Required(ErrorMessage = "角色名称不能为空")]
    [StringLength(50, MinimumLength = 2, ErrorMessage = "角色名称长度必须在2-50个字符之间")]
    [RegularExpression(@"^[a-zA-Z0-9_\u4e00-\u9fa5]+$", ErrorMessage = "角色名称只能包含字母、数字、下划线和中文")]
    public string Name { get; set; } = string.Empty;

    [StringLength(200, ErrorMessage = "角色描述长度不能超过200个字符")]
    public string? Description { get; set; }
    
    [StringLength(20, ErrorMessage = "角色状态长度不能超过20个字符")]
    public string Status { get; set; } = "active";

    public List<Guid> MenuIds { get; set; } = new List<Guid>();
}

/// <summary>
/// 角色更新请求DTO
/// </summary>
public class UpdateRoleRequestDto
{
    [Required(ErrorMessage = "角色ID不能为空")]
    public Guid Id { get; set; }

    [Required(ErrorMessage = "角色名称不能为空")]
    [StringLength(50, MinimumLength = 2, ErrorMessage = "角色名称长度必须在2-50个字符之间")]
    [RegularExpression(@"^[a-zA-Z0-9_\u4e00-\u9fa5]+$", ErrorMessage = "角色名称只能包含字母、数字、下划线和中文")]
    public string Name { get; set; } = string.Empty;

    [StringLength(200, ErrorMessage = "角色描述长度不能超过200个字符")]
    public string? Description { get; set; }
    
    [StringLength(20, ErrorMessage = "角色状态长度不能超过20个字符")]
    public string Status { get; set; } = "active";

    public List<Guid> MenuIds { get; set; } = new List<Guid>();
}

/// <summary>
/// 角色查询请求DTO
/// </summary>
public class GetRolesRequestDto
{
    public string? Name { get; set; }
    public string? Description { get; set; }
    public string? Status { get; set; }
    public int PageIndex { get; set; } = 1;
    public int PageSize { get; set; } = 10;
}

/// <summary>
/// 角色响应DTO
/// </summary>
public class RoleResponseDto
{
    public Guid Id { get; set; }
    public string Name { get; set; } = string.Empty;
    public string? Description { get; set; }
    public string Status { get; set; } = "active";
    public DateTime CreatedAt { get; set; }
    public DateTime UpdatedAt { get; set; }
    public List<MenuDto> Menus { get; set; } = new List<MenuDto>();
    public int UserCount { get; set; }
}

/// <summary>
/// 菜单DTO
/// </summary>
public class MenuDto
{
    public Guid Id { get; set; }
    public string Name { get; set; } = string.Empty;
    public string? Path { get; set; }
    public string? Icon { get; set; }
    public int Order { get; set; }
    public string? PermissionKey { get; set; }
}

/// <summary>
/// 角色列表响应DTO
/// </summary>
public class RoleListResponseDto
{
    public List<RoleResponseDto> Roles { get; set; } = new List<RoleResponseDto>();
    public int TotalCount { get; set; }
    public int PageIndex { get; set; }
    public int PageSize { get; set; }
    public int TotalPages { get; set; }
} 